Repository navigation
[2.1] Fixes #37164: Only Approved glossary terms can be applied through the API - #37688
Conversation
… API (#37643) * Fixes #37164: Only Approved glossary terms can be applied through the API The UI only offers Approved glossary terms when tagging an asset, but the API accepted Draft, In Review, Rejected and Deprecated terms on every write path. ApprovedGlossaryTermGuard now rejects, per target (asset or inline field), any glossary term that is newly applied and not Approved: on create, PUT, PATCH, bulk PUT, the table dataModel, a term's assets/add, the column API, and the column bulk-update / CSV previews. A term already held on the same target stays, so writes that carry it back still pass. * Judge bulk creates per input and match moved fields by name path createMany runs the glossary-term guard in BulkEntityCreator.prepare so a rejected input fails alone instead of failing the request. The updater keys the updated entity's targets by the stored FQN of the same name path, so a container move that rewrites its data-model column FQNs before the stored labels are re-keyed does not make a held term look new. Adds tests for both and for the column bulk-update and CSV dry-run previews. * Find tagged fields per repository and compare terms by hash The guard took nested fields from ChildFieldResolver, which leaves File columns out, and keyed name paths by field name alone, so a request and a response field with the same name collided. Fields now come from EntityRepository.taggedFieldContainers (FileRepository adds its columns), name paths carry the container path and ignore case like column matching, and terms are compared by FQN hash so a quoted FQN cannot slip past. * Keep IT fixture names short and record the ingestion decision The createMany test case's suite is named after its table, so the table now lives under a short service and schema. The container move test reads back with tags. The decision record notes that bots get no exemption and that dbt skips non-Approved terms client-side (#37256), shipping together. * Test the bulk PUT update rejection and document assets/add Adds the IT step for a bulk PUT that adds a Deprecated term to an existing table. assets/add rejects a non-Approved term for every asset in the request, as the endpoint only applies terms; the Javadoc and ADR now say so. * Approve the moved term before tagging it in the move-rewrite IT test_approvedGlossaryTermMoveRewritesTaggedAssetsInSearch tagged a table with a term still In Review, which is now refused. The test approves the term through its own approval task first; the aboutEntity filter matches by FQN prefix, so the task is picked by the term's id, not the first one. * Judge a column CSV dry-run in one guard call The dry-run called the approved-term guard once per row, so a file with many glossary-tagged rows looked terms up row by row on the request thread. It now pools every row's labels per column, runs the guard once for the file, and judges each row by its own terms against the shared result. (cherry picked from commit 9803398)
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
| Map<String, Set<String>> previewRejections = | ||
| dryRun ? previewRejections(parsedRows, occurrencesByName) : Map.of(); |
There was a problem hiding this comment.
💡 Edge Case: One malformed term FQN aborts the whole CSV dry run
previewRejections runs once, before the per-row loop and outside its try/catch. It hands every row's glossary-term FQNs to ApprovedGlossaryTermGuard.rejectedTermHashesByTarget. That path hashes each requested FQN (termHash → FullyQualifiedName.buildHash, and findEntityByNames hashes them again), and buildHash throws IllegalArgumentException(invalidFQN) when a value fails to parse, for example Glossary."Bad. So one row with a malformed term makes the whole dry-run import fail with an error. The real import (dryRun=false) handles the same row inside the per-row try/catch and only that row fails. The preview then no longer matches the apply, which the ADR and the method's Javadoc say it should, and before this PR the same file previewed fine. Fix: hash each row's terms on their own and leave out (and count as failed) the rows whose FQNs do not parse, before the single guard call.
Leave rows whose term FQNs do not parse out of the pooled guard call; the per-row loop then fails them the way the apply would.:
for (String[] fields : parsedRows) {
List<TagLabel> tags = rowTags(fields);
if (!hasParseableTermFqns(tags)) {
continue;
}
for (ColumnOccurrence occurrence : listOrEmpty(occurrencesByName.get(fields[0]))) {
tagsByColumn
.computeIfAbsent(occurrence.getColumnFQN(), column -> new ArrayList<>())
.addAll(tags);
}
}
Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 🟡 Medium risk 0 closed / 1 findingsEnforcing Approved-only glossary tagging across asset and column APIs could cause ingestion writes that newly apply non-approved terms to fail. Backports the approved-only glossary term guard to 2.1 so the API rejects newly applied non-Approved terms with a 400, matching the UI rule while keeping previously applied terms and re-sent writes working. Approved with suggestions: a malformed term FQN in one CSV row makes the whole dry-run preview in 💡 Edge Case: One malformed term FQN aborts the whole CSV dry run📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java:1077-1078 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ColumnRepository.java:1128-1142 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ApprovedGlossaryTermGuard.java:146-160 📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/ApprovedGlossaryTermGuard.java:225-227
Leave rows whose term FQNs do not parse out of the pooled guard call; the per-row loop then fails them the way the apply would.🤖 Prompt for agentsVerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #37164
Backport of #37643 to
2.1. It's a clean cherry-pick of squash commit98033981f8, with no conflicts.The API now rejects, with a 400, any write that newly applies a glossary term that is not Approved, the same rule the UI already enforces. It covers create, PUT, PATCH, bulk PUT,
createMany, a glossary term'sassets/add, the column APIs and their dry-run previews, and the tabledataModel(dbt) endpoint. A term that leaves Approved after it was applied stays on the asset, and writes that re-send it still pass. See #37643 for the design anddocs/decisions/2026-11-06-only-approved-glossary-terms-can-be-newly-applied-to-an-asset.md.dbt's client-side skip of non-Approved terms is tracked in #37256 and should ship in the same release.
Type of change:
Tests:
Run locally on this branch (MySQL + Elasticsearch):
ApprovedGlossaryTermGuardTest,TagLabelUtilTestandColumnRepositoryImportTest. 46 run, 0 failures.GlossaryTermApprovedTaggingIT: 19 run, 0 failures.The full IT and Playwright evidence is on #37643.
Checklist:
[2.1] Fixes <issue-number>: <short explanation>Fixes #<issue-number>above.🤖 Generated with Claude Code